package org.adl.registry.types;

import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;

/**
 *
 * @author Jacob Marks - Joint ADL Co-Lab
 * @version 1.0
 * @license This software is licensed as open source software pursuant to the terms defined in the Joint ADL Co-Lab Open Source Software License.  Use of any part of this software constitutes acceptance of this license. The Joint ADL Co-Lab open source agreement is available at {@link http://adlregistry.adlnet.gov/source_license.html}.
 */
public class Email extends RimParameter
{
    /**
     * Creates a new instance of Email
     */
    public Email(String iValue)
    {
        super("email", iValue);
        
        this.validate();
    }
    
    protected void validate()
    {
        try
        {
            InternetAddress email = Email.getInternetAddress(super.getParameterValue());
        }
        catch (AddressException ex)
        {
            super.getValidaionErrors().add(ex.getMessage());
        }
    }
    
    public static InternetAddress getInternetAddress(String iEmail)
    throws AddressException
    {
        InternetAddress email = new InternetAddress(iEmail, true);
        
        return email;
    }
}
